// components/crabArea/crabArea.ts
Component({
    // behaviors:["wx://component-export"],
    // export(){
    //     return {
    //         myValue:"111"
    //     }
    // },
    properties: {
        data:{
            type:Object,
            value:{}
        }
    },
    options:{
        addGlobalClass:true
    },
    data: {
        // crabData:{}, //每条数据的信息
        sellNumber:0, //加购数量
    },
    methods: {
        // 点击加购图标事件监听
        addNumber(){
            let sellNumber=this.data.sellNumber+1;
            this.triggerEvent("addCart",{
                id:this.properties.data.id,
                price:this.properties.data.price
            });
            this.setData({
                sellNumber
            });
        },
        // 点击减购图标事件监听
        minusNumber(){
            let sellNumber=this.data.sellNumber === 0 ? 0 :this.data.sellNumber-1;
            this.triggerEvent("minusCart",{
                id:this.properties.data.id,
                price:this.properties.data.price
            });
            this.setData({
                sellNumber
            });
        },
        // 更新视图数据方法事件监听
        update(){
            let sellNumber=this.properties.data.number;
            this.setData({
                sellNumber
            });
        }
    },
    ready(){
        this.update();
    }
});
